﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp9
{
    class Program
    {
        delegate void Fun();
        public class Clock
        {
            private int H { get; set; }
            private int M { get; set; }
            private DateTime date;
            public Clock()
            {
                H = DateTime.Now.Hour + (DateTime.Now.Minute + 1) / 60;
                M = (DateTime.Now.Minute + 1) % 60;
                date = DateTime.Now;
            }
            public void Alarm()
            {
                if (date.Hour == H && date.Minute == M)
                {
                    Console.WriteLine(" " + date.ToString() + " Ring!!!Ring!!!Ring!!!");
                }
            }
            public void Tick()
            {
                while (date.Hour <= H && date.Minute < M)
                {
                    Console.WriteLine(" " + date.ToString() + " Tick...Tick...Tick...");
                    System.Threading.Thread.Sleep(1000);
                    date = DateTime.Now;
                }
            }
        }
        static void Main(string[] args)
        {
            Clock clock = new Clock();
            Fun fun = new Fun(clock.Tick);
            fun += clock.Alarm;
            fun();
            Console.ReadKey();
            return;
        }
    }
}
